package com.woniuxy.ams.service.impl;

import com.woniuxy.ams.dao.AssessStandardDao;
import com.woniuxy.ams.dao.AssessTypeDao;
import com.woniuxy.ams.entity.AssessStandard;
import com.woniuxy.ams.entity.AssessType;
import com.woniuxy.ams.service.AssessTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssessTypeServiceImpl implements AssessTypeService {

    @Autowired
    AssessTypeDao assessTypeDao;

    @Autowired
    AssessStandardDao assessStandardDao;
    /**
     * 查询所有
     * @param data
     * @return
     */
    @Override
    public List<AssessType> findAllAssessType( AssessType data) {

        return assessTypeDao.findAllAssessType(data);
    }


    /**
     * 添加
     * @param assessType
     * @return
     */
    @Override
    public boolean addAssessType(AssessType assessType) {

        int i = assessTypeDao.addAssessType(assessType);
        if (i == 1){
            return true;
        }else {
            return false;
        }


    }

    /**
     * 删除
     * @param assessType
     * @return
     */
    @Override
    public boolean deleteAssessType(AssessType assessType) {
        Integer id = assessType.getId();
        int i = assessTypeDao.deleteAssessType(id);
        return i == 1;
    }

    /**
     * 修改
     * @param assessType
     * @return
     */
    @Override
    public boolean updateAssessType(AssessType assessType) {
        int i = assessTypeDao.updateAssessType(assessType);
        return i == 1;
    }

    /**
     * 根据id查询
     * @param
     * @return
     */
    @Override
    public List<AssessType> findById(AssessStandard assessStandard) {
        String name = assessStandard.getName();
        int[] ids = assessStandardDao.findTheassessmentNameByName(name);
        return assessTypeDao.findById(ids);
    }
    /**
     * 根据考核种类查询
     * @return
     */
    @Override
    public AssessType findByAssessmentTypes(AssessType assessType) {
        System.out.println(assessType);
        return assessTypeDao.findByAssessmentTypes(assessType);
    }

    @Override
    public List<AssessType> findByTypeId(AssessType assessType) {
        int id = assessType.getId();
        System.out.println(id);
        return assessTypeDao.findByTypeId(id);
    }

    @Override
    public List<AssessType> findAll() {
        return assessTypeDao.findAll();
    }
}
